* Nicolai Petrovsky
* nicolai.petrovsky@uky.edu


* This do-file generates all variables and obtains all results reported 
* in the Public Money & Management (2011) article 
* "Leadership Succession and Organisational Success: When Do New Chief 
* Executives Make a Difference?" 
* by George A. Boyne, Oliver James, Peter John, and Nicolai Petrovsky


* Stata version 11.1
* last modified May 11, 2013


* The first step you have to take is to download our data set from the 
* UK Data Archive.  Please go to 
* http://store.data-archive.ac.uk/store/
* and on the right-hand side, under "SEARCH PROJECTS", 
* search for "Petrovsky".  
* You will be taken to our data set.  

* Please download it (the filename is BoyneJamesJohnPetrovsky.dta) and 
* save it in the same directory as this do-file.  

* Then , please use Stata's command
* cd
* to change to that directory.

* Now you can run this do-file.


* How to find the result(s) you are interested in: 

* Since there is a lot of material in this do-file, you can find the results 
* for the items that most interest you in the following way: 
* After running this do-file, view the log file (PMM2011.smcl) and search within it for 
* "Page 344" if you would like to see a result from page 344 in the article; same 
* for all other pages with results.  
* (For searchin within the log-file, click the search button on the top left-hand 
*  side of the Stata viewer.)


clear
clear matrix
version 11.1
set more off
set memory 200m
set scheme s1mono

* Open a log and allow for replacement
log using PMM2011.smcl, replace

* Open data
use BoyneJamesJohnPetrovsky.dta
save workfile, replace

* Page 342: "We define baseline organizational performance of more 
* than one standard deviation above the mean as high, and baseline 
* organizational performance of more than one standard deviation below 
* the mean as low.

* Create the necessary variables and interaction terms
* baseline performance (low if sp_per 1 sd below grand mean or worse):
gen low_sp_per = .
replace low_sp_per = 0 if sp_per >= 59.947291 & sp_per ~= .
replace low_sp_per = 1 if sp_per < 59.947291 & sp_per ~= .
sum low_sp_per
gen hi_sp_per = .
replace hi_sp_per = 0 if sp_per <= 77.223409 & sp_per ~= .
replace hi_sp_per = 1 if sp_per > 77.223409 & sp_per ~= .
sum hi_sp_per
* previous CEO's tenure
gen prev_tenure = .
replace prev_tenure = L1.tenure if newceo == 1
replace prev_tenure = L2.tenure if (L1.newceo == 1 & newceo == 0)
replace prev_tenure = L3.tenure if (L2.newceo == 1 & /*
*/ L1.newceo == 0 & newceo == 0)
replace prev_tenure = L4.tenure if (L3.newceo == 1 & /*
*/ L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L5.tenure if (L4.newceo == 1 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L6.tenure if (L5.newceo == 1 & /*
*/ L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L7.tenure if (L6.newceo == 1 & /*
*/ L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L8.tenure if (L7.newceo == 1 & /*
*/ L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L9.tenure if (L8.newceo == 1 & /*
*/ L7.newceo == 0 & L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)
replace prev_tenure = L10.tenure if (L9.newceo == 1 & L8.newceo == 0 & /*
*/ L7.newceo == 0 & L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L1.newceo == 0 & newceo == 0)

* interaction terms
gen newceoXprev_tenure = newceo * prev_tenure
gen newceoXoutside = newceo * outside
gen newceoXlow_sp_per = newceo * low_sp_per
gen newceoXhi_sp_per = newceo * hi_sp_per
gen prev_tenureXoutside = prev_tenure * outside
gen prev_tenureXlow_sp_per = prev_tenure * low_sp_per
gen prev_tenureXhi_sp_per = prev_tenure * hi_sp_per
gen outsideXlow_sp_per = outside * low_sp_per
gen outsideXhi_sp_per = outside * hi_sp_per
gen newceoXprev_tenureXoutside = newceo * prev_tenure * outside
gen newceoXprev_tenureXlow_sp_per = newceo * prev_tenure * low_sp_per
gen newceoXprev_tenureXhi_sp_per = newceo * prev_tenure * hi_sp_per
gen newceoXoutsideXlow_sp_per = newceo * outside * low_sp_per
gen newceoXoutsideXhi_sp_per = newceo * outside * hi_sp_per
gen prev_tenureXoutsideXlow_sp_per = prev_tenure * outside * low_sp_per
gen prev_tenureXoutsideXhi_sp_per = prev_tenure * outside * hi_sp_per

* aggregate external finance
* Definition: 
* The total amount of money given by central government to local government. 
* It consists of the Revenue Support Grant (RSG), ringfenced and other specific 
* grants and redistributed business rates. Councils raise money on top of this through council tax.
* Source: http://www.idea.gov.uk/idk/core/page.do?pageId=1092259 (last accessed 23 June 2009)
gen aef = outgrants + ingrants + rsg + ndr_receipts

* Political change
gen pol_l0_ceo = newceo * controlchange
gen l1controlchange = L1.controlchange
gen pol_l1_ceo = newceo * l1controlchange
gen l0l1controlchange = .
replace l0l1controlchange = 0 if controlchange ~= . & l1controlchange ~= .
replace l0l1controlchange = 1 if controlchange == 1
replace l0l1controlchange = 1 if l1controlchange == 1
gen pol_l0l1_ceo = newceo * l0l1controlchange
gen hi_s_l0l1controlchange = hi_sp_per * l0l1controlchange
gen hi_s_pol_l0l1_ceo = hi_sp_per * pol_l0l1_ceo
gen lo_s_l0l1controlchange = low_sp_per * l0l1controlchange
gen lo_s_pol_l0l1_ceo = low_sp_per * pol_l0l1_ceo

* TMT turnover rate
gen ceoXto1 = newceo * F1.to1
gen hi_s_to1 = F1.to1 * hi_sp_per
gen hi_s_ceoXto1 = ceoXto1 * hi_sp_per
gen lo_s_to1 = F1.to1 * low_sp_per
gen lo_s_ceoXto1 = ceoXto1 * low_sp_per

compress
save, replace

* REDEFINE newceo AND THE OTHER Xs AS ONE-YEAR LAGS
gen l1newceo = L1.newceo
replace newceo = l1newceo
drop l1newceo
gen LAGlow_sp_per = L1.low_sp_per
replace low_sp_per = LAGlow_sp_per
drop LAGlow_sp_per
gen LAGhi_sp_per = L1.hi_sp_per
replace hi_sp_per = LAGhi_sp_per
drop LAGhi_sp_per
gen LAGoutside = L1.outside
replace outside = LAGoutside
drop LAGoutside
gen LAGprev_tenure = L1.prev_tenure
replace prev_tenure = LAGprev_tenure
drop LAGprev_tenure
gen LAGnewceoXprev_tenure = L1.newceoXprev_tenure
replace newceoXprev_tenure = LAGnewceoXprev_tenure
drop LAGnewceoXprev_tenure
gen LAGnewceoXoutside = L1.newceoXoutside
replace newceoXoutside = LAGnewceoXoutside
drop LAGnewceoXoutside
gen LAGnewceoXlow_sp_per = L1.newceoXlow_sp_per
replace newceoXlow_sp_per = LAGnewceoXlow_sp_per
drop LAGnewceoXlow_sp_per
gen LAGprev_tenureXoutside = L1.prev_tenureXoutside
replace prev_tenureXoutside = LAGprev_tenureXoutside
drop LAGprev_tenureXoutside
gen LAGprev_tenureXlow_sp_per = L1.prev_tenureXlow_sp_per
replace prev_tenureXlow_sp_per = LAGprev_tenureXlow_sp_per
drop LAGprev_tenureXlow_sp_per
gen LAGoutsideXlow_sp_per = L1.outsideXlow_sp_per
replace outsideXlow_sp_per = LAGoutsideXlow_sp_per
drop LAGoutsideXlow_sp_per
gen LAGnewceoXprev_tenureXoutside = L1.newceoXprev_tenureXoutside
replace newceoXprev_tenureXoutside = LAGnewceoXprev_tenureXoutside
drop LAGnewceoXprev_tenureXoutside
gen LAGnewceoXprev_tenureXlow_s = L1.newceoXprev_tenureXlow_sp_per
replace newceoXprev_tenureXlow_sp_per = LAGnewceoXprev_tenureXlow_s
drop LAGnewceoXprev_tenureXlow_s
gen LAGnewceoXoutsideXlow_sp_per = L1.newceoXoutsideXlow_sp_per
replace newceoXoutsideXlow_sp_per = LAGnewceoXoutsideXlow_sp_per
drop LAGnewceoXoutsideXlow_sp_per
gen LAGprev_tenureXoutsideXlow_s = L1.prev_tenureXoutsideXlow_sp_per
replace prev_tenureXoutsideXlow_sp_per = LAGprev_tenureXoutsideXlow_s
drop LAGprev_tenureXoutsideXlow_s
gen LAGnewceoXhi_sp_per = L1.newceoXhi_sp_per
replace newceoXhi_sp_per = LAGnewceoXhi_sp_per
drop LAGnewceoXhi_sp_per
gen LAGprev_tenureXhi_sp_per = L1.prev_tenureXhi_sp_per
replace prev_tenureXhi_sp_per = LAGprev_tenureXhi_sp_per
drop LAGprev_tenureXhi_sp_per
gen LAGoutsideXhi_sp_per = L1.outsideXhi_sp_per
replace outsideXhi_sp_per = LAGoutsideXhi_sp_per
drop LAGoutsideXhi_sp_per
gen LAGnewceoXprev_tenureXhi_sp_per = L1.newceoXprev_tenureXhi_sp_per
replace newceoXprev_tenureXhi_sp_per = LAGnewceoXprev_tenureXhi_sp_per
drop LAGnewceoXprev_tenureXhi_sp_per
gen LAGnewceoXoutsideXhi_sp_per = L1.newceoXoutsideXhi_sp_per
replace newceoXoutsideXhi_sp_per = LAGnewceoXoutsideXhi_sp_per
drop LAGnewceoXoutsideXhi_sp_per
gen LAGprev_tenureXoutsideXhi_sp_per = L1.prev_tenureXoutsideXhi_sp_per
replace prev_tenureXoutsideXhi_sp_per = LAGprev_tenureXoutsideXhi_sp_per
drop LAGprev_tenureXoutsideXhi_sp_per

* Political change
gen LAGcontrolchange = L1.controlchange
drop controlchange
rename LAGcontrolchange controlchange
gen LAGpol_l0_ceo = L1.pol_l0_ceo
drop pol_l0_ceo
rename LAGpol_l0_ceo pol_l0_ceo
gen LAGl1controlchange = L1.l1controlchange
drop l1controlchange
rename LAGl1controlchange l1controlchange
gen LAGpol_l1_ceo = L1.pol_l1_ceo
drop pol_l1_ceo
rename LAGpol_l1_ceo pol_l1_ceo
gen LAGl0l1controlchange = L1.l0l1controlchange
drop l0l1controlchange
rename LAGl0l1controlchange l0l1controlchange
gen LAGpol_l0l1_ceo = L1.pol_l0l1_ceo
drop pol_l0l1_ceo
rename LAGpol_l0l1_ceo pol_l0l1_ceo

* TMT turnover rate
gen LAGto1 = L1.to1
drop to1
rename LAGto1 to1
gen LAGceoXto1 = L1.ceoXto1
drop ceoXto1
rename LAGceoXto1 ceoXto1

gen LAGhi_s_to1 = L1.hi_s_to1
drop hi_s_to1
rename LAGhi_s_to1 hi_s_to1

gen LAGhi_s_ceoXto1 = L1.hi_s_ceoXto1
drop hi_s_ceoXto1
rename LAGhi_s_ceoXto1 hi_s_ceoXto1

gen LAGlo_s_to1 = L1.lo_s_to1
drop lo_s_to1
rename LAGlo_s_to1 lo_s_to1

gen LAGlo_s_ceoXto1 = L1.lo_s_ceoXto1
drop lo_s_ceoXto1
rename LAGlo_s_ceoXto1 lo_s_ceoXto1

compress
save, replace

* Analyses

* Make common estimation sample
quietly ivreg D1.sp_per D1.newceo /*
*/ D1.newceoXhi_sp_per /*
*/ D1.newceoXlow_sp_per /*
*/ D1.controlchange /*
*/ D1.pol_l0_ceo /*
*/ D1.outside /*
*/ D1.newceoXoutside /*
*/ D1.to1 /*
*/ D1.ceoXto1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per)
gen esample = 1 if e(sample)


* Page 343: Table 1 (Summary statistics for the common estimation sample 
* of all models containing chief executive successions one year ago 
* (285 observations).

sum sp_per newceo /*
*/ hi_sp_per low_sp_per /*
*/ controlchange /*
*/ outside /*
*/ to1 if esample == 1

* Page 344: Model 1.1 in Table 2 (Testing for effects of chief executive succession.)

ivreg D1.sp_per D1.newceo /*
*/ D1.controlchange /*
*/ D1.outside /*
*/ D1.to1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per) if esample == 1, cluster(lacode)
* outreg using PMM_Model0_L1.txt, /*
*/ title(Table 2, Model 0, L1) /*
*/ ctitle((0.L1)) bdec(2) tdec(2) 3aster nor2 replace

* Obtain number of observations
gen d1ceo = D1.newceo
tab d1ceo if e(sample)
tab newceo if e(sample)

* Page 344: Model 2.1 in Table 2 (Testing for effects of chief executive succession.)

ivreg D1.sp_per D1.newceo D1.newceoXhi_sp_per D1.newceoXlow_sp_per /*
*/ D1.controlchange /*
*/ D1.outside /*
*/ D1.to1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per) if esample == 1, cluster(lacode)
* outreg using PMM_Model1_L1.txt, /*
*/ title(Table 2, Model 1, L1) /*
*/ ctitle((1.L1)) bdec(2) tdec(2) 3aster nor2 replace

* Obtain number of observations
gen D1newceoXhi_sp_per = D1.newceoXhi_sp_per
gen D1newceoXlow_sp_per = D1.newceoXlow_sp_per
tab D1newceoXhi_sp_per if e(sample)
tab D1newceoXlow_sp_per if e(sample)
tab newceoXhi_sp_per if e(sample)
tab newceoXlow_sp_per if e(sample)

* Get coefficients, variances, and covariances (taking into account
* that in the Anderson-Hsiao results the first RHS variable is the
* lagged dependent variable):
matrix b=e(b)
matrix V=e(V)
forval i = 1(1)3 {
   scalar b`i'=b[1,`i'+1]
   dis "Check b`i' is correct:"
   dis b`i'
   scalar varb`i'=V[`i'+1,`i'+1]
   forval j = 1(1)3 {
      scalar covb`i'b`j'=V[`i'+1,`j'+1]
   }
}

gen me2hi = b1*1 /*
*/ + b2*1*1

gen se2hi = sqrt(varb1 /*
*/ + varb2*(1*1)^2 /*
*/ + 2*covb1b2*(1*1))

gen z2hi = me2hi/se2hi

gen me2lo = b1*1 /*
*/ + b3*1*1

gen se2lo = sqrt(varb1 /*
*/ + varb3*(1*1)^2 /*
*/ + 2*covb1b3*(1*1))

gen z2lo = me2lo/se2lo

* MFX of CEO succession given high baseline performance:
sum me2hi z2hi

* MFX of CEO succession given mediocre baseline performance:
* = coefficient estimate on D1.newceo

* MFX of CEO succession given low baseline performance:
sum me2lo z2lo

clear
clear matrix
erase workfile.dta

* Open data
use BoyneJamesJohnPetrovsky.dta
save workfile, replace

* Page 342: "We define baseline organizational performance of more 
* than one standard deviation above the mean as high, and baseline 
* organizational performance of more than one standard deviation below 
* the mean as low.

* Create the necessary variables and interaction terms
* baseline performance (low if sp_per 1 sd below grand mean or worse):
gen low_sp_per = .
replace low_sp_per = 0 if sp_per >= 59.947291 & sp_per ~= .
replace low_sp_per = 1 if sp_per < 59.947291 & sp_per ~= .
sum low_sp_per
gen hi_sp_per = .
replace hi_sp_per = 0 if sp_per <= 77.223409 & sp_per ~= .
replace hi_sp_per = 1 if sp_per > 77.223409 & sp_per ~= .
sum hi_sp_per
* previous CEO's tenure
gen prev_tenure = .
replace prev_tenure = L2.tenure if newceo == 1
replace prev_tenure = L2.tenure if (L2.newceo == 1 & newceo == 0)
replace prev_tenure = L3.tenure if (L2.newceo == 1 & /*
*/ L2.newceo == 0 & newceo == 0)
replace prev_tenure = L4.tenure if (L3.newceo == 1 & /*
*/ L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L5.tenure if (L4.newceo == 1 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L6.tenure if (L5.newceo == 1 & /*
*/ L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L7.tenure if (L6.newceo == 1 & /*
*/ L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L8.tenure if (L7.newceo == 1 & /*
*/ L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L9.tenure if (L8.newceo == 1 & /*
*/ L7.newceo == 0 & L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)
replace prev_tenure = L10.tenure if (L9.newceo == 1 & L8.newceo == 0 & /*
*/ L7.newceo == 0 & L6.newceo == 0 & L5.newceo == 0 & L4.newceo == 0 & /*
*/ L3.newceo == 0 & L2.newceo == 0 & L2.newceo == 0 & newceo == 0)

* Pages 341-342: "Some chief executives only 
* serve about a year, while the longest-serving chief executives in our dataset, 
* of Gateshead Council until 2003/04, and of Staffordshire County Council, until 
* 2002/03, were in post for two full decades."

sum prev_tenure, d
tab prev_tenure
list lacode year if prev_tenure == 20 & prev_tenure ~= .

* interaction terms
gen newceoXprev_tenure = newceo * prev_tenure
gen newceoXoutside = newceo * outside
gen newceoXlow_sp_per = newceo * low_sp_per
gen newceoXhi_sp_per = newceo * hi_sp_per
gen prev_tenureXoutside = prev_tenure * outside
gen prev_tenureXlow_sp_per = prev_tenure * low_sp_per
gen prev_tenureXhi_sp_per = prev_tenure * hi_sp_per
gen outsideXlow_sp_per = outside * low_sp_per
gen outsideXhi_sp_per = outside * hi_sp_per
gen newceoXprev_tenureXoutside = newceo * prev_tenure * outside
gen newceoXprev_tenureXlow_sp_per = newceo * prev_tenure * low_sp_per
gen newceoXprev_tenureXhi_sp_per = newceo * prev_tenure * hi_sp_per
gen newceoXoutsideXlow_sp_per = newceo * outside * low_sp_per
gen newceoXoutsideXhi_sp_per = newceo * outside * hi_sp_per
gen prev_tenureXoutsideXlow_sp_per = prev_tenure * outside * low_sp_per
gen prev_tenureXoutsideXhi_sp_per = prev_tenure * outside * hi_sp_per

* aggregate external finance
* Definition: 
* The total amount of money given by central government to local government. 
* It consists of the Revenue Support Grant (RSG), ringfenced and other specific 
* grants and redistributed business rates. Councils raise money on top of this through council tax.
* Source: http://www.idea.gov.uk/idk/core/page.do?pageId=1092259 (last accessed 23 June 2009)
gen aef = outgrants + ingrants + rsg + ndr_receipts

* Political change
gen pol_l0_ceo = newceo * controlchange
gen l1controlchange = L2.controlchange
gen pol_l1_ceo = newceo * l1controlchange
gen l0l1controlchange = .
replace l0l1controlchange = 0 if controlchange ~= . & l1controlchange ~= .
replace l0l1controlchange = 1 if controlchange == 1
replace l0l1controlchange = 1 if l1controlchange == 1
gen pol_l0l1_ceo = newceo * l0l1controlchange
gen hi_s_l0l1controlchange = hi_sp_per * l0l1controlchange
gen hi_s_pol_l0l1_ceo = hi_sp_per * pol_l0l1_ceo
gen lo_s_l0l1controlchange = low_sp_per * l0l1controlchange
gen lo_s_pol_l0l1_ceo = low_sp_per * pol_l0l1_ceo

* TMT turnover rate
gen ceoXto1 = newceo * F1.to1
gen hi_s_to1 = F1.to1 * hi_sp_per
gen hi_s_ceoXto1 = ceoXto1 * hi_sp_per
gen lo_s_to1 = F1.to1 * low_sp_per
gen lo_s_ceoXto1 = ceoXto1 * low_sp_per

compress
save, replace

* REDEFINE newceo AND THE OTHER Xs AS TWO-YEAR LAGS
gen l1newceo = L2.newceo
replace newceo = l1newceo
drop l1newceo
gen LAGlow_sp_per = L2.low_sp_per
replace low_sp_per = LAGlow_sp_per
drop LAGlow_sp_per
gen LAGhi_sp_per = L2.hi_sp_per
replace hi_sp_per = LAGhi_sp_per
drop LAGhi_sp_per
gen LAGoutside = L2.outside
replace outside = LAGoutside
drop LAGoutside
gen LAGprev_tenure = L2.prev_tenure
replace prev_tenure = LAGprev_tenure
drop LAGprev_tenure
gen LAGnewceoXprev_tenure = L2.newceoXprev_tenure
replace newceoXprev_tenure = LAGnewceoXprev_tenure
drop LAGnewceoXprev_tenure
gen LAGnewceoXoutside = L2.newceoXoutside
replace newceoXoutside = LAGnewceoXoutside
drop LAGnewceoXoutside
gen LAGnewceoXlow_sp_per = L2.newceoXlow_sp_per
replace newceoXlow_sp_per = LAGnewceoXlow_sp_per
drop LAGnewceoXlow_sp_per
gen LAGprev_tenureXoutside = L2.prev_tenureXoutside
replace prev_tenureXoutside = LAGprev_tenureXoutside
drop LAGprev_tenureXoutside
gen LAGprev_tenureXlow_sp_per = L2.prev_tenureXlow_sp_per
replace prev_tenureXlow_sp_per = LAGprev_tenureXlow_sp_per
drop LAGprev_tenureXlow_sp_per
gen LAGoutsideXlow_sp_per = L2.outsideXlow_sp_per
replace outsideXlow_sp_per = LAGoutsideXlow_sp_per
drop LAGoutsideXlow_sp_per
gen LAGnewceoXprev_tenureXoutside = L2.newceoXprev_tenureXoutside
replace newceoXprev_tenureXoutside = LAGnewceoXprev_tenureXoutside
drop LAGnewceoXprev_tenureXoutside
gen LAGnewceoXprev_tenureXlow_s = L2.newceoXprev_tenureXlow_sp_per
replace newceoXprev_tenureXlow_sp_per = LAGnewceoXprev_tenureXlow_s
drop LAGnewceoXprev_tenureXlow_s
gen LAGnewceoXoutsideXlow_sp_per = L2.newceoXoutsideXlow_sp_per
replace newceoXoutsideXlow_sp_per = LAGnewceoXoutsideXlow_sp_per
drop LAGnewceoXoutsideXlow_sp_per
gen LAGprev_tenureXoutsideXlow_s = L2.prev_tenureXoutsideXlow_sp_per
replace prev_tenureXoutsideXlow_sp_per = LAGprev_tenureXoutsideXlow_s
drop LAGprev_tenureXoutsideXlow_s
gen LAGnewceoXhi_sp_per = L2.newceoXhi_sp_per
replace newceoXhi_sp_per = LAGnewceoXhi_sp_per
drop LAGnewceoXhi_sp_per
gen LAGprev_tenureXhi_sp_per = L2.prev_tenureXhi_sp_per
replace prev_tenureXhi_sp_per = LAGprev_tenureXhi_sp_per
drop LAGprev_tenureXhi_sp_per
gen LAGoutsideXhi_sp_per = L2.outsideXhi_sp_per
replace outsideXhi_sp_per = LAGoutsideXhi_sp_per
drop LAGoutsideXhi_sp_per
gen LAGnewceoXprev_tenureXhi_sp_per = L2.newceoXprev_tenureXhi_sp_per
replace newceoXprev_tenureXhi_sp_per = LAGnewceoXprev_tenureXhi_sp_per
drop LAGnewceoXprev_tenureXhi_sp_per
gen LAGnewceoXoutsideXhi_sp_per = L2.newceoXoutsideXhi_sp_per
replace newceoXoutsideXhi_sp_per = LAGnewceoXoutsideXhi_sp_per
drop LAGnewceoXoutsideXhi_sp_per
gen LAGprev_tenureXoutsideXhi_sp_per = L2.prev_tenureXoutsideXhi_sp_per
replace prev_tenureXoutsideXhi_sp_per = LAGprev_tenureXoutsideXhi_sp_per
drop LAGprev_tenureXoutsideXhi_sp_per

* Political change
gen LAGcontrolchange = L2.controlchange
drop controlchange
rename LAGcontrolchange controlchange
gen LAGpol_l0_ceo = L2.pol_l0_ceo
drop pol_l0_ceo
rename LAGpol_l0_ceo pol_l0_ceo
gen LAGl1controlchange = L2.l1controlchange
drop l1controlchange
rename LAGl1controlchange l1controlchange
gen LAGpol_l1_ceo = L2.pol_l1_ceo
drop pol_l1_ceo
rename LAGpol_l1_ceo pol_l1_ceo
gen LAGl0l1controlchange = L2.l0l1controlchange
drop l0l1controlchange
rename LAGl0l1controlchange l0l1controlchange
gen LAGpol_l0l1_ceo = L2.pol_l0l1_ceo
drop pol_l0l1_ceo
rename LAGpol_l0l1_ceo pol_l0l1_ceo

* TMT turnover rate
gen LAGto1 = L2.to1
drop to1
rename LAGto1 to1
gen LAGceoXto1 = L2.ceoXto1
drop ceoXto1
rename LAGceoXto1 ceoXto1

gen LAGhi_s_to1 = L2.hi_s_to1
drop hi_s_to1
rename LAGhi_s_to1 hi_s_to1

gen LAGhi_s_ceoXto1 = L2.hi_s_ceoXto1
drop hi_s_ceoXto1
rename LAGhi_s_ceoXto1 hi_s_ceoXto1

gen LAGlo_s_to1 = L2.lo_s_to1
drop lo_s_to1
rename LAGlo_s_to1 lo_s_to1

gen LAGlo_s_ceoXto1 = L2.lo_s_ceoXto1
drop lo_s_ceoXto1
rename LAGlo_s_ceoXto1 lo_s_ceoXto1

compress
save, replace

* Analyses

* Make common estimation sample
quietly ivreg D1.sp_per D1.newceo /*
*/ D1.newceoXhi_sp_per /*
*/ D1.newceoXlow_sp_per /*
*/ D1.controlchange /*
*/ D1.pol_l0_ceo /*
*/ D1.outside /*
*/ D1.newceoXoutside /*
*/ D1.to1 /*
*/ D1.ceoXto1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per)
gen esample = 1 if e(sample)

* Page 344: Model 1.2 in Table 2 (Testing for effects of chief executive succession.)

ivreg D1.sp_per D1.newceo /*
*/ D1.controlchange /*
*/ D1.outside /*
*/ D1.to1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per) if esample == 1, cluster(lacode)
* outreg using PMM_Model0_L2.txt, /*
*/ title(Table 2, Model 0, L2) /*
*/ ctitle((0.L2)) bdec(2) tdec(2) 3aster nor2 replace

* Obtain number of observations
gen d1ceo = D1.newceo
tab d1ceo if e(sample)
tab newceo if e(sample)

* Page 344: Model 2.2 in Table 2 (Testing for effects of chief executive succession.)

ivreg D1.sp_per D1.newceo D1.newceoXhi_sp_per D1.newceoXlow_sp_per /*
*/ D1.controlchange /*
*/ D1.outside /*
*/ D1.to1 /*
*/ D1.y2005 (LD.sp_per = L2.sp_per) if esample == 1, cluster(lacode)
* outreg using PMM_Model1_L2.txt, /*
*/ title(Table 2, Model 1, L2) /*
*/ ctitle((1.L2)) bdec(2) tdec(2) 3aster nor2 replace

* Obtain number of observations
gen D1newceoXhi_sp_per = D1.newceoXhi_sp_per
gen D1newceoXlow_sp_per = D1.newceoXlow_sp_per
tab D1newceoXhi_sp_per if e(sample)
tab D1newceoXlow_sp_per if e(sample)
tab newceoXhi_sp_per if e(sample)
tab newceoXlow_sp_per if e(sample)

* Get coefficients, variances, and covariances (taking into account
* that in the Anderson-Hsiao results the first RHS variable is the
* lagged dependent variable):
matrix b=e(b)
matrix V=e(V)
forval i = 1(1)3 {
   scalar b`i'=b[1,`i'+1]
   dis "Check b`i' is correct:"
   dis b`i'
   scalar varb`i'=V[`i'+1,`i'+1]
   forval j = 1(1)3 {
      scalar covb`i'b`j'=V[`i'+1,`j'+1]
   }
}

gen me2hi = b1*1 /*
*/ + b2*1*1

gen se2hi = sqrt(varb1 /*
*/ + varb2*(1*1)^2 /*
*/ + 2*covb1b2*(1*1))

gen z2hi = me2hi/se2hi

gen me2lo = b1*1 /*
*/ + b3*1*1

gen se2lo = sqrt(varb1 /*
*/ + varb3*(1*1)^2 /*
*/ + 2*covb1b3*(1*1))

gen z2lo = me2lo/se2lo

* MFX of CEO succession given high baseline performance:
sum me2hi z2hi

* MFX of CEO succession given mediocre baseline performance:
* = coefficient estimate on D1.newceo

* MFX of CEO succession given low baseline performance:
sum me2lo z2lo

log close
clear
clear matrix
erase workfile.dta
exit

* You can now view a record of all operations in the PMM2011.smcl file.  
